package com.telit.firecommand.controller.pub;//package com.telit.firecommand.controller.pub;
//
//import com.alibaba.fastjson.JSON;
//import com.telit.constant.Constant;
//import com.telit.entity.DataReturn;
//import com.telit.enums.ResultCode;
//import com.telit.firecommand.constant.RedisKeyConstant;
//import com.telit.firecommand.dto.DistrictCountDTO;
//import com.telit.firecommand.model.camera.QryDistrictListByCodesRequest;
//import com.telit.firecommand.service.CameraInfoService;
//import com.telit.firecommand.service.CameraMonitorService;
//import com.telit.firecommand.vo.CameraVO;
//import com.telit.firecommand.vo.FirePointResourceVO;
//import com.telit.util.RedisUtils;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.ArrayList;
//import java.util.List;
//
//
///**
// * 临时演示使用
// */
//@Slf4j
//@RestController
//@RequestMapping("/pub/camera-info")
//@Api(tags = "开放监控设备信息处理接口", description = "camera-info")
//public class CameraInfoPubController {
//
//    @Autowired
//    private CameraMonitorService cameraMonitorService;
//
//    @Autowired
//    private CameraInfoService cameraInfoService;
//
//    @PostMapping("/cacheCameraPosition")
//    @ApiOperation(value = "缓存监控设备用于首页展示", httpMethod = Constant.REQUEST_METHOD_POST)
//    public DataReturn cacheCameraPosition(@RequestBody List<CameraVO> voList,
//                                          @RequestParam(value = "districtCode") String districtCode) {
//        try {
//            if (voList == null || districtCode == null) {
//                return DataReturn.failure(ResultCode.FORM_PARAMS_CHECK_ERROR);
//            }
//            RedisUtils.set(RedisKeyConstant.CAMERA_POSITION + districtCode, JSON.toJSONString(voList));
//            return DataReturn.ok();
//        } catch (Exception e) {
//            e.printStackTrace();
//            return DataReturn.failure();
//        }
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//    })
//    @GetMapping("/getCameraPosition")
//    @ApiOperation(value = "获取首页展示监控设备", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn<List<CameraVO>> getCameraPosition(@RequestParam(value = "districtCode") String districtCode) {
//        try {
//            List<CameraVO> voList = cameraInfoService.getCameraPosition(districtCode);
//            List<CameraVO> effectiveList = new ArrayList<>();
//            for (CameraVO object : voList) {
//                String previewUrl = RedisUtils.get(RedisKeyConstant.CAMERA_PREVIEW_URL + object.getId());
//                if (StringUtils.isEmpty(previewUrl)) {
//                    //获取并缓存
//                    try {
//                        previewUrl = cameraMonitorService.queryFlvpUrl(object.getId());
//                    } catch (Exception ex) {
//                        log.error(ex.getMessage(), ex);
//                        continue;
//                    }
//                }
//                object.setPreviewUrl(previewUrl);
//                effectiveList.add(object);
//            }
//            return DataReturn.ok(effectiveList);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return DataReturn.failure();
//        }
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "type", value = "类型", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "online", value = "在线  1在线 2离线", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "cameraName", value = "监控名称（模糊查询）", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//    })
//    @GetMapping(value = "/qry-district-list-by-parent-code")
//    @ApiOperation(value = "根据父行政区划编码查询子类集合，初始化时请传递省份code（安徽省：34）", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn<DistrictCountDTO> qryDistrictListByParentCode(
//            @RequestParam(value = "type", required = false) Integer type,
//            @RequestParam(value = "online", required = false) Integer online,
//            @RequestParam(value = "cameraName", required = false) String cameraName,
//            @RequestParam(value = "districtCode") String districtCode) {
//        return DataReturn.ok(cameraInfoService.qryDistrictListByParentCode(type, online, cameraName, districtCode));
//    }
//
//    @PostMapping(value = "/qry-district-list-by-codes")
//    @ApiOperation(value = "根据行政区划编码批量查询", httpMethod = Constant.REQUEST_METHOD_POST)
//    public DataReturn<DistrictCountDTO> qryDistrictListByCodes(
//            QryDistrictListByCodesRequest qryDistrictListByCodesRequest) {
//        return DataReturn.ok(cameraInfoService.qryDistrictListByCodes(qryDistrictListByCodesRequest));
//    }
//
////    @Deprecated
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
////            @ApiImplicitParam(name = "fireId", value = "火情id", required = true, paramType = "query", dataType = "String"),
////            @ApiImplicitParam(name = "firePoint", value = "火点信息，例如 point(经纬+纬度)", required = true, paramType = "query", dataType = "String"),
////    })
////    @GetMapping(value = "/qry-camera-list-by-point")
////    @ApiOperation(value = "根据火点信息查询实时视频", httpMethod = Constant.REQUEST_METHOD_GET)
////    public DataReturn<FirePointResourceVO> qryCameraListByPoint(
////            @RequestParam(value = "districtCode") String districtCode,
////            @RequestParam(value = "fireId") String fireId,
////            @RequestParam(value = "firePoint") String firePoint) {
////        return DataReturn.ok(FirePointResourceVO.builder().cameraList(
////                cameraInfoService.qryCameraListByPoint(districtCode, fireId, firePoint)).build());
////    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "fireId", value = "火情id", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "firePoint", value = "火点信息，例如 point(经纬+纬度)", required = true, paramType = "query", dataType = "String"),
//    })
//    @GetMapping(value = "/qry-cache-resource-by-point")
//    @ApiOperation(value = "根据火点信息查询缓存资源", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn<FirePointResourceVO> qryCacheResourceByPoint(
//            @RequestParam(value = "districtCode") String districtCode, @RequestParam(value = "fireId") String fireId,
//            @RequestParam(value = "firePoint") String firePoint) {
//        return DataReturn.ok(cameraInfoService.qryCacheResourceByPoint(districtCode, fireId, firePoint));
//    }
//
////    @Deprecated
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
////            @ApiImplicitParam(name = "fireId", value = "火情id", required = true, paramType = "query", dataType = "String"),
////    })
////    @PostMapping(value = "/cache-camera-by-point")
////    @ApiOperation(value = "缓存火场态势首页实时视频", httpMethod = Constant.REQUEST_METHOD_POST)
////    public DataReturn cacheCameraByPoint(@RequestParam(value = "districtCode") String districtCode,
////                                         @RequestParam(value = "fireId") String fireId,
////                                         @RequestBody CameraVO cameraVO) {
////        cameraInfoService.cacheCameraByPoint(districtCode, fireId, cameraVO);
////        return DataReturn.ok();
////    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "fireId", value = "火情id", required = true, paramType = "query", dataType = "String"),
//    })
//    @PostMapping(value = "/cache-resource-by-point")
//    @ApiOperation(value = "缓存火场态势首页资源", httpMethod = Constant.REQUEST_METHOD_POST)
//    public DataReturn cacheResourceByPoint(@RequestParam(value = "districtCode") String districtCode,
//                                           @RequestParam(value = "fireId") String fireId,
//                                           @RequestBody FirePointResourceVO firePointResourceVO) {
//        cameraInfoService.cacheResourceByPoint(districtCode, fireId, firePointResourceVO);
//        return DataReturn.ok();
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "firePoint", value = "火点信息，例如 point(经纬+纬度)", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "keyWords", value = "搜索关键字", paramType = "query", dataType = "String"),
//    })
//    @GetMapping(value = "/qry-resource-list-by-point")
//    @ApiOperation(value = "根据火点信息查询资源", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn<FirePointResourceVO> qryResourceListByPoint(
//            @RequestParam(value = "districtCode") String districtCode,
//            @RequestParam(value = "firePoint") String firePoint,
//            @RequestParam(value = "keyWords", required = false) String keyWords) {
//        return DataReturn.ok(cameraInfoService.qryResourceListByPoint(districtCode, firePoint, keyWords));
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "districtCode", value = "行政区划", required = true, paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "pageSize", value = "页面大小", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "type", value = "监控类型", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "online", value = "在线  1在线 2离线", paramType = "query", dataType = "String"),
//            @ApiImplicitParam(name = "cameraName", value = "监控名称", paramType = "query", dataType = "String"),
//    })
//    @GetMapping(value = "/pageList")
//    @ApiOperation(value = "监控列表", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn<List<CameraVO>> pageList(
//            @RequestParam(value = "districtCode") String districtCode,
//            @RequestParam(value = "pageNum") Integer pageNum,
//            @RequestParam(value = "pageSize") Integer pageSize,
//            @RequestParam(value = "type", required = false) Integer type,
//            @RequestParam(value = "online", required = false) Integer online,
//            @RequestParam(value = "cameraName", required = false) String cameraName) {
//        return DataReturn.ok(cameraInfoService.pageList(districtCode, pageNum, pageSize, type, online, cameraName));
//    }
//
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "String"),
//    })
//    @GetMapping(value = "/findOne")
//    @ApiOperation(value = "监控详情", httpMethod = Constant.REQUEST_METHOD_GET)
//    public DataReturn findOne(@RequestParam(value = "id") String id) {
//        return DataReturn.ok(cameraInfoService.findOne(id));
//    }
//
//}
